package eu.vranckaert.workRegistrationWidget.service.impl;

import android.content.Context;
import eu.vranckaert.workRegistrationWidget.R;
import eu.vranckaert.workRegistrationWidget.domain.TimeRegistration;
import eu.vranckaert.workRegistrationWidget.service.WidgetLayoutBuilderService;
import eu.vranckaert.workRegistrationWidget.util.DateUtil;

/**
 * @Author Dirk Vranckaert
 * Date: 28-apr-2010
 * Time: 22:41:20
 */
public class WidgetLayoutBuilderServiceImpl implements WidgetLayoutBuilderService {
    public String getRegistrationText(Context context, TimeRegistration timeRegistration) {
        String fullText;

        if (timeRegistration != null && timeRegistration.getStartDate() != null) {
            String dateTime = "";
            String startedStopped = "";
            if (timeRegistration.getEndDate() == null) {
                dateTime = DateUtil.formatDateTimeInCurrentLocale(timeRegistration.getStartDate(), context);
                startedStopped = context.getString(R.string.widget_str_regSubTextStarted);
            } else {
                dateTime = DateUtil.formatDateTimeInCurrentLocale(timeRegistration.getEndDate(), context);
                startedStopped = context.getString(R.string.widget_str_regSubTextStopped);
            }
            fullText = dateTime + " (" + startedStopped + ")";
        } else {
            fullText = context.getString(R.string.widget_str_regTextNone);
        }

        return fullText;
    }

    public String getRegistrationButtonText(Context context, TimeRegistration timeRegistration) {
        String startStopButtonText = "";
        if (timeRegistration != null && timeRegistration.getEndDate() == null && timeRegistration.getStartDate() != null) {
            startStopButtonText = context.getString(R.string.widget_btn_stopReg);
        } else {
            startStopButtonText = context.getString(R.string.widget_btn_startReg);
        }

        return startStopButtonText;
    }
}
